package com.autonavi.collapse;

import com.autonavi.collapse.config.DataSourceConfig;
import com.autonavi.collapse.task.TaskContainer;
import com.autonavi.collapse.task.context.SpringContextManager;
import com.autonavi.collapse.task.context.TaskComponentContainer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        ApplicationContext content = SpringApplication.run(Application.class, args);
        init(DataSourceConfig.GROUP, content);
    }

    public static void init(String group, ApplicationContext context) {
        try {
            SpringContextManager manager = new SpringContextManager(context,"com.autonavi.collapse.task");
            TaskComponentContainer.init(manager);
        } catch (Exception e) {
            e.printStackTrace();
        }
        TaskContainer taskContainer = new TaskContainer();
        try {
            taskContainer.init();
            taskContainer.start(group,"taskDataSource");
        }catch (Exception e) {
            e.printStackTrace();
        }

    }

}
